#include<bits/stdc++.h>
using namespace std;
int n,m,L,V;
struct Node{
    long long l,r;
};
const int N=1e5+5;
int c[N];
int T;
Node p[N];
Node q[N];
bool cmp(Node x,Node y){
    if(x.l==y.l) return x.r<y.r;
    else return x.l<y.l;
}
void solve(){
    int ans=0;
    scanf("%d%d%d%d",&n,&m,&L,&V);
    int d,v,a;
    int k=0;
    for(int i=1;i<=n;i++){
        scanf("%d%d%d",&d,&v,&a);
        if(a==0){
            if(v>V) p[i].l=d,p[i].r=L,k++;
            else p[i].l=p[i].r=0;
            continue;
        }
        long long s;
        s=(V+v)*(V-v)/(2*a);
        if(a>0){
            if(v>V) p[i].l=d,p[i].r=L;
            else if(d+s+1>L) p[i].l=p[i].r=0;
            else p[i].l=d+s+1,p[i].r=L;
        }
        if(a<0){
            if(v<V) p[i].l=p[i].r=0;
            else{
                int k;
                if(s*(2*a)==V*V-v*v) k=d+s-1;
                else k=d+s;
                if(k>L) p[i].l=d,p[i].r=L;
                else p[i].l=d,p[i].r=k;
            }
        }
    }
    for(int i=1;i<=m;i++) scanf("%d",&c[i]);
    for(int i=1;i<=n;i++){
        int l,r;
        if(p[i].l==0){
            q[i].l=q[i].r=INT_MAX;
            continue;
        }
        l=lower_bound(c+1,c+1+m,p[i].l)-c;
        r=lower_bound(c+1,c+1+m,p[i].r)-c;
        if(r==m+1) r=m;
        if(l==m+1){
            q[i].l=q[i].r=INT_MAX;
            continue;
        }
        if(c[r]>p[i].r) r--;
        if(c[l]>p[i].r) q[i].l=q[i].r=INT_MAX;
        else q[i].l=l,q[i].r=r,ans++;
    }
    sort(q+1,q+n+1,cmp);
    printf("%d ",ans);
    if(ans==0){
        printf("%d\n",m);
        return;
    } 
    ans=0;
    int l=q[1].l,r=q[1].r;
    for(int i=1;i<=n;i++){
        if(q[i].l==INT_MAX){
            break;
        }
        if(q[i].l>=l&&q[i].r<=r) l=q[i].l,r=q[i].r;
        else if(q[i].l>r) ans++,l=q[i].l,r=q[i].r;
        else if(r>=q[i].l) l=q[i].l;
    }
    ans++;
    printf("%d\n",m-ans);
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&T);
    while(T--){
        solve();
    }
}